package leetcode.tree;

import leetcode.tree.common.TreeNode;
import leetcode.tree.common.TreeUtils;

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 * int val;
 * TreeNode left;
 * TreeNode right;
 * TreeNode() {}
 * TreeNode(int val) { this.val = val; }
 * TreeNode(int val, TreeNode left, TreeNode right) {
 * this.val = val;
 * this.left = left;
 * this.right = right;
 * }
 * }
 */
class Solution333 {
    public int largestBSTSubtree(TreeNode root) {
        return TreeUtils.largestBSTSubtree(root);
    }
}

public class leetcode333 {
    public static void main(String[] args) {
        Solution333 solution333 = new Solution333();
        Integer[] nums = {10, 5, 15, 1, 8, null, 7};
        Integer[] nums1 = {3, 2, 4, null, null, 1};
        System.out.println(solution333.largestBSTSubtree(TreeUtils.generateLeetcodeTree(nums))); // 3
        System.out.println(solution333.largestBSTSubtree(TreeUtils.generateLeetcodeTree(nums1))); // 2
    }
}
